<template>
  <div class="app-container">
    <div v-show="active === 1">
      <div class="searchform">
        <!-- 查询条件 -->
        <el-form ref="searchForm" :model="search" size="mini" label-width="90px">
          <el-row :gutter="6">
            <el-col :xs="24" :sm="8" :md="6">
              <el-form-item prop="employeeName" label="员工姓名">
                <el-input v-model="search.employeeName" placeholder="员工姓名" clearable />
              </el-form-item>
            </el-col>
            <el-col :xs="24" :sm="8" :md="6">
              <el-form-item prop="employeeCode" label="员工编号">
                <el-input v-model="search.employeeCode" placeholder="员工编号" clearable />
              </el-form-item>
            </el-col>
            <el-col :xs="24" :sm="8" :md="6">
              <el-form-item prop="userCode" label="员工帐号">
                <el-input v-model="search.userCode" placeholder="员工帐号" clearable/>
              </el-form-item>
            </el-col>
            <el-col :xs="24" :sm="8" :md="6">
              <el-form-item prop="orgName" label="所属组织">
                <el-input v-model="search.orgName" placeholder="所属组织" clearable />
              </el-form-item>
            </el-col>
            <el-col :xs="24" :sm="8" :md="6">
              <el-form-item prop="isOnjob" label="在职状态">
                <el-select v-model="search.isOnjob" :clearable="true" placeholder="请选择" >
                  <el-option v-for="item in isOnjob" :key="item.code" :label="item.name" :value="item.code">{{ item.name }}</el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <div style="text-align:right">
              <el-button type="primary" icon="el-icon-search" @click="searchHandle">查询
              </el-button>
              <el-button icon="el-icon-refresh" @click="resetForm('searchForm')">重置
              </el-button>
            </div>
          </el-row>
        </el-form>
      </div>
      <!-- 用户列表 -->
      <div class="table">
        <div class="tableHead">
          <div class="tabletitle">授权信息</div>
          <!--<div class="btnGroup">
            <el-button-group>
              <el-button type="primary" icon="el-icon-plus" @click="add">权限统一分配
              </el-button>
            </el-button-group>
          </div>-->
        </div>
        <BaseTable ref="table" @chaneg-size="changeSizeHandle" @chaneg-page="changePageHandle" @selection-change="handleSelectionChange">
          <el-table-column type="index" label="序号" min-width="50"/>
          <!--          <el-table-column type="selection" min-width="40"/>-->
          <el-table-column align="center" label="操作" min-width="100">
            <template slot-scope="scope">
              <el-tooltip class="item" content="编辑" placement="bottom">
                <el-button
                  :disabled="scope.row.USER_STATUS === 10031002||scope.row.IS_ONJOB === 10081002"
                  type="text"
                  style="font-size: 20px;"
                  icon="el-icon-edit-outline"
                  @click="edit(scope.row)"/>
              </el-tooltip>
              <!--              <el-tooltip class="item" content="停用" placement="bottom">-->
              <!--                <el-popover placement="top" width="160" v-model="scope.row.visible">-->
              <!--                  <p>确定停用吗？</p>-->
              <!--                  <div style="text-align: right; margin: 0">-->
              <!--                    <el-button size="mini" type="text" @click="scope.row.visible = false">取消</el-button>-->
              <!--                    <el-button type="primary" size="mini" @click="scope.row.visible = false;stop(scope.row)">确定</el-button>-->
              <!--                  </div>-->
              <!--                  <el-button type="text" style="font-size: 20px;" :disabled="scope.row.USER_STATUS === 10031002||scope.row.IS_ONJOB === 10081002"-->
              <!--                    slot="reference"  title="停用" icon="el-icon-error" @click="scope.row.visible = true"></el-button>-->
              <!--                </el-popover>-->
              <!--              </el-tooltip>-->
              <!--              <el-tooltip class="item" content="启用" placement="bottom">-->
              <!--                <el-popover placement="top" width="160" v-model="scope.row.visible">-->
              <!--                  <p>确定启用吗？</p>-->
              <!--                  <div style="text-align: right; margin: 0">-->
              <!--                    <el-button size="mini" type="text" @click="scope.row.visible = false">取消</el-button>-->
              <!--                    <el-button type="primary" size="mini" @click="scope.row.visible = false;start(scope.row)">确定</el-button>-->
              <!--                  </div>-->
              <!--                  <el-button type="text" style="font-size: 20px;" :disabled="scope.row.USER_STATUS === 10031001||scope.row.IS_ONJOB === 10081002"-->
              <!--                             slot="reference"  title="启用" icon="el-icon-success" @click="scope.row.visible = true"></el-button>-->
              <!--                </el-popover>-->
              <!--              </el-tooltip>-->
              <el-tooltip v-if="scope.row.USER_CODE" class="item" content="禁用" placement="bottom">
                <el-button
                  :disabled="scope.row.USER_STATUS === 10031002||scope.row.IS_ONJOB === 10081002?true:false"
                  type="text"
                  icon="el-icon-error"
                  style="font-size: 20px;"
                  align="center"
                  @click="disableStatus(scope.row)" /></el-tooltip>
              <el-tooltip v-if="scope.row.USER_CODE" class="item" content="启用" placement="bottom">
                <el-button
                  :disabled="scope.row.USER_STATUS === 10031001||scope.row.IS_ONJOB === 10081002?true:false"
                  type="text"
                  icon="el-icon-success"
                  style="font-size: 20px;"
                  align="center"
                  @click="enableStatus(scope.row)" /></el-tooltip>
              <el-tooltip v-if="scope.row.WHITE_FLAG === 10041002" class="item" content="加入白名单" placement="bottom">
                <el-button
                  type="text"
                  icon="el-icon-circle-plus"
                  style="font-size: 20px;"
                  align="center"
                  @click="enableWhite(10041001, scope.row.EMP_ID)" />
              </el-tooltip>
              <el-tooltip v-if="scope.row.WHITE_FLAG === 10041001" class="item" content="移除白名单" placement="bottom">
                <el-button
                  type="text"
                  icon="el-icon-remove"
                  style="font-size: 20px;"
                  align="center"
                  @click="enableWhite(10041002, scope.row.EMP_ID)" />
              </el-tooltip>
            </template>
          </el-table-column>
          <el-table-column prop="EMPLOYEE_NAME" label="员工姓名"/>
          <el-table-column prop="EMPLOYEE_NO" label="员工编号"/>
          <el-table-column prop="USER_CODE" label="员工账号" />
          <el-table-column :show-overflow-tooltip="true" prop="ORG_NAME" width="120" label="组织" />
          <el-table-column :show-overflow-tooltip="true" prop="POSITION_NAME" width="120" label="职位" />
          <el-table-column :show-overflow-tooltip="true" prop="ROLE_NAME" width="120" label="角色" />
          <!--<el-table-column prop="DEALER_NAME" label="任职公司" min-width="130">-->
          <!--</el-table-column>-->
          <!--<el-table-column prop="IS_MAJOR" label="是否主任职公司" min-width="120">-->
          <!--<template slot-scope="scope">-->
          <!--<filtercode v-model="scope.row.IS_MAJOR" type="1004" />-->
          <!--</template>-->
          <!--</el-table-column>-->
          <!--          <el-table-column prop="EMP_POSITION" label="挂靠职位" min-width="600">-->
          <!--          </el-table-column>-->

          <el-table-column :formatter="filterCode" prop="IS_ONJOB" label="是否在职" type="1008"/>
          <el-table-column :formatter="formatDate" prop="CREATED_AT" label="创建日期"/>
          <el-table-column :formatter="formatDate" prop="STOP_DATE" label="停用日期"/>
        </BaseTable>
      </div>
    </div>
    <!-- 新增div -->
    <div v-show="active === 2">
      <el-form ref="addSearchForm" :inline="true" :model="search" size="mini">
        <div class="table">
          <div class="tableHead">
            <div class="tabletitle">职位信息</div>
            <div class="btnGroup">
              <el-button-group>
                <el-button type="primary" icon="el-icon-plus" @click="openRole">新增</el-button>
              </el-button-group>
            </div>
          </div>
          <BaseTableNoPage ref="table1" @chaneg-size="changeSizeHandle" @chaneg-page="changePageHandle">
            <el-table-column type="index" label="序号" min-width="20"/>
            <el-table-column align="center" label="操作" min-width="20">
              <template slot-scope="scope">
                <el-tooltip class="item" content="删除" placement="bottom">
                  <el-button type="text" style="font-size: 20px;" icon="el-icon-delete" @click="table1Delete(scope.$index, scope.row)"/>
                </el-tooltip>
              </template>
            </el-table-column>
            <el-table-column prop="POSITION_CODE" label="职位代码" min-width="50"/>
            <el-table-column prop="POSITION_NAME" label="职位名称" min-width="50"/>
          </BaseTableNoPage>
        </div>
        <div style="text-align:center">
          <el-button type="primary" @click="save">保存</el-button>
          <el-button @click="clear">返回</el-button>
        </div>
      </el-form>

    </div>
    <!-- 编辑div -->
    <div v-show="active === 3">
      <el-form
        v-dialogDrag
        ref="editSearchForm"
        :model="form"
        :rules="rules"
        size="mini"
        label-width="90px"
        label-position="right">
        <div class="searchform">
          <el-row :gutter="6">
            <el-col :xs="24" :sm="8" :md="6">
              <el-form-item label="员工编号" prop="employeeNo">
                <el-input v-model="form.employeeNo" disabled="disabled" placeholder="员工编号" />
              </el-form-item>
            </el-col>
            <el-col :xs="24" :sm="8" :md="6">
              <el-form-item label="账号" prop="userCode">
                <el-input v-model="form.userCode" :disabled="userCodeShow" placeholder="账号" />
              </el-form-item>
            </el-col>
            <el-col :xs="24" :sm="8" :md="6">
              <el-form-item label="姓名" prop="employeeName">
                <el-input v-model="form.employeeName" disabled="disabled" placeholder="姓名" />
              </el-form-item>
            </el-col>
            <el-col :xs="24" :sm="8" :md="6">
              <el-form-item prop="userStatus" label="用户状态">
                <el-select v-model="form.userStatus" :clearable="true" placeholder="请选择" >
                  <el-option v-for="item in userStatus" :key="item.code" :label="item.name" :value="item.code">{{ item.name }}</el-option>
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>
        </div>
        <div class="table">
          <div class="tableHead">
            <div class="tabletitle">职位信息</div>
            <div class="btnGroup">
              <el-button-group>
                <el-button type="primary" icon="el-icon-plus" @click="openRole">新增</el-button>
              </el-button-group>
            </div>
          </div>
          <BaseTableNoPage ref="table2" @chaneg-size="changeSizeHandle" @chaneg-page="changePageHandle">
            <el-table-column type="index" label="序号" min-width="20"/>
            <el-table-column align="center" label="操作" min-width="40">
              <template slot-scope="scope">
                <el-tooltip class="item" content="删除" placement="bottom">
                  <el-button type="text" style="font-size: 20px;" icon="el-icon-delete" @click="table2Delete(scope.$index, scope.row)"/>
                </el-tooltip>
                <el-tooltip v-if="scope.row.IS_DEFAULT == 10041002" class="item" content="默认职位变更" placement="bottom">
                  <el-button type="text" style="font-size: 20px;" icon="el-icon-check" @click="tableDefault(scope.$index, scope.row)"/>
                </el-tooltip>
              </template>
            </el-table-column>
            <!--            <el-table-column :formatter="filterCode" prop="AREA_TYPE" label="业务范围" type="4503"/>-->
            <el-table-column prop="ORG_NAME" label="所属组织" min-width="50"/>
            <el-table-column prop="POSITION_CODE" label="职位代码" min-width="50"/>
            <el-table-column prop="POSITION_NAME" label="职位名称" min-width="50"/>
            <!--            <el-table-column :formatter="filterCode" prop="IS_SYNC_BEIDI" label="是否传电商" min-width="50" type="1004"/>-->
            <el-table-column :formatter="filterCode" prop="IS_DEFAULT" label="是否默认" min-width="50" type="1004"/>
          </BaseTableNoPage>
        </div>
        <div style="text-align:center">
          <el-button type="primary" @click="editSave">保存</el-button>
          <el-button @click="clear">返回</el-button>
        </div>
      </el-form>
    </div>
    <!-- 弹框 -->
    <el-dialog v-dialogDrag :append-to-body="true" :visible.sync="dialogVisible" title="职位模板选择" width="70%">
      <div class="searchform">
        <!-- 查询条件 -->
        <el-form ref="searchForm" :model="roleSearch" size="mini" label-width="90px">
          <el-row :gutter="6">
            <el-col :xs="24" :sm="8" :md="6">
              <el-form-item prop="positionCode" label="职位代码">
                <el-input v-model="roleSearch.positionCode" placeholder="职位代码" clearable />
              </el-form-item>
            </el-col>
            <el-col :xs="24" :sm="8" :md="6">
              <el-form-item prop="positionName" label="职位名称">
                <el-input v-model="roleSearch.positionName" placeholder="职位名称" clearable />
              </el-form-item>
            </el-col>
            <div style="text-align:right">
              <el-button type="primary" icon="el-icon-search" @click="searchRole">查询
              </el-button>
              <el-button icon="el-icon-refresh" @click="resetForm('searchForm')">重置
              </el-button>
            </div>
          </el-row>
        </el-form>
      </div>
      <!-- 用户列表 -->
      <div class="table">
        <div class="tableHead">
          <div class="tabletitle">职位信息</div>
        </div>
        <el-table
          v-loading="load"
          ref="roleTable"
          :data="list"
          tooltip-effect="dark"
          style="width: 100%"
          stripe
          border
          @selection-change="SelectionChange">
          <el-table-column type="index" width="50" label="序号"/>
          <el-table-column type="selection" width="40"/>
          <el-table-column prop="POSITION_CODE" label="职位代码" min-width="50"/>
          <el-table-column prop="POSITION_NAME" label="职位名称" min-width="50"/>
          <!--          <el-table-column :formatter="filterCode" prop="AREA_TYPE" label="业务范围" type="4503"/>-->
          <el-table-column prop="ORG_NAME" label="所属组织" min-width="50"/>
          <!--          <el-table-column :formatter="filterCode" prop="IS_SYNC_BEIDI" label="是否传电商" type="1004"/>-->
        </el-table>
        <!-- 分页 -->
        <Pagination :data="page" @change-size="handleSizeChange" @change-page="handleCurrentChange" />
      </div>
      <div slot="footer" class="dialog-footer" style="text-align:center">
        <!-- <span slot="footer" class="dialog-footer"> -->
        <el-button type="primary" @click="req">确 定</el-button>
        <el-button @click="dialogVisible = false">取 消</el-button>

        <!-- </span> -->
      </div>
    </el-dialog>

  </div>
</template>

<script>
import {
  getAuthList,
  getAuthListById,
  SaveAuth,
  getModelList,
  stopById,
  startById,
  whiteEnable
} from '@/api/admin/auth/gms/authManagement'
import {
  getUserInfoById
} from '@/api/admin/org/gms/employeeInfo'
import Pagination from '@/components/Pagination'
import BaseTable from '@/components/BaseTable'
import BaseTableNoPage from '@/components/BaseTable/BaseTableNoPage'
import formMixins from '@/mixins/formMixins'
import rSelect from '@/components/Select/Select'
import filtercode from '@/components/Checkbox/filtercode'
import _ from 'lodash'
import { codeCheck } from '@/utils/validator'
export default {
  name: 'AuthorizationManagement',
  components: {
    BaseTable,
    BaseTableNoPage,
    Pagination,
    rSelect,
    filtercode
  },
  mixins: [formMixins],
  data() {
    return {
      active: 1,

      list: [],
      load: false,
      page: {},
      multipleSelection: [],
      authSelection: [],
      returnList: [],
      EMPLOYEE_ID: '',
      userCodeShow: true,
      ids: 0,
      type: 0,
      search: {
        limit: 10,
        pageNum: 1,
        employeeCode: '',
        employeeName: '',
        orgName: '',
        userCode: '',
        isOnjob: '',
        isPartCustomer: ''
      },
      roleSearch: {
        limit: 10,
        pageNum: 1,
        positionCode: '',
        positionName: ''
      },
      // 用户状态
      userStatus: [{
        code: 10031001,
        name: '启用'
      },
      {
        code: 10031002,
        name: '离职'
      }
      ],

      // 在职状态
      isOnjob: [{
        code: 10081001,
        name: '在职'
      },
      {
        code: 10081002,
        name: '离职'
      }
      ],
      options: [{
        value: '0',
        label: '员工'
      }, {
        value: '1',
        label: '往来客户'
      }],
      dialogVisible: false,
      rules: {
        userCode: [{
          required: true,
          message: '请输入账号',
          trigger: 'blur'
        },
        { trigger: 'blur', validator: codeCheck }
        ],
        userStatus: [{
          required: true,
          message: '请选择用户状态',
          trigger: 'blur'
        }]
      },
      form: {
        userCode: '',
        employeeNo: '',
        employeeName: '',
        userStatus: 10031001
      }
    }
  },
  computed: {},
  watch: {
    '$route.params.employeeName'(val, oldval) {
      const employeeName = this.$route.params.employeeName
      if (employeeName) {
        this.search.employeeName = employeeName
        this.searchHandle()
      }
    }
  },
  mounted() {
    const employeeName = this.$route.params.employeeName
    if (employeeName) { this.search.employeeName = employeeName }
    this.searchHandle()
  },
  methods: {
    // 查询
    searchHandle() {
      const table = this.$refs['table']
      const search = _.extend(this.search)
      table.wait()
      getAuthList(search).then(res => {
        table.complete().filData(res)
      }).catch(err => {
        table.complete()
      })
    },
    // 查询角色模板选择列表
    openRole() {
      this.dialogVisible = true
      this.searchRole()
    },
    searchRole() {
      this.load = true
      getModelList(this.roleSearch)
        .then(res => {
          this.list = res.rows
          this.page = res
          this.load = false
        })
        .catch(err => {
          this.load = false
        })
    },
    // 统一分配权限
    add() {
      if (this.authSelection.length === 0) {
        this.$message({
          type: 'info',
          message: '请选择数据!'
        })
      } else {
        for (var i = 0; i < this.authSelection.length; i++) {
          if (this.ids === 0) {
            this.ids = this.authSelection[i].EMPLOYEE_ID
            this.type = this.authSelection[i].DATA_SOURCES
          } else {
            this.ids += ',' + this.authSelection[i].EMPLOYEE_ID
            if (this.type !== this.authSelection[i].DATA_SOURCES) {
              this.$message({
                type: 'info',
                message: '请选择相同类型的数据!'
              })
              return
            }
          }
          if (this.authSelection[i].IS_ONJOB === '10081002') {
            this.$message({
              type: 'info',
              message: '包含已离职员工信息不能统一分配!'
            })
            return
          }
          if (this.authSelection[i].USER_STATUS === '10031002') {
            this.$message({
              type: 'info',
              message: '包含已禁用员工信息不能统一分配!'
            })
            return
          }
        }
        this.active = 2
        console.log(this.ids, this.type)
      }
    },
    // 编辑
    edit(data) {
      this.userCodeShow = false
      this.active = 3
      const table2 = this.$refs['table2']
      this.EMPLOYEE_ID = data.EMP_ID
      this.type = data.DATA_SOURCES
      getUserInfoById(data.EMP_ID)
        .then(res => {
          // this.form = _.cloneDeep(res);
          if (res.USER_CODE) {
            this.form.userCode = res.USER_CODE
          } else {
            this.form.userCode = data.EMPLOYEE_NO
          }
          this.form.employeeNo = res.EMPLOYEE_NO
          this.form.employeeName = res.EMPLOYEE_NAME
          this.form.userStatus = res.USER_STATUS
          // if (res[0].USER_CODE === null) {
          //   this.userCodeShow = false;
          // }
        })
        .catch(err => {
          // table.complete()
        })
      this.$nextTick(() => {
        this.$refs.editSearchForm.clearValidate()
      })
      getAuthListById(this.EMPLOYEE_ID).then(res => {
        table2.complete().filData(res)
      }).catch(err => {
        table2.complete()
      })
    },
    // 删除
    table1Delete(index, row) {
      const table1 = this.$refs.table1
      table1.delete(index)
    },
    table2Delete(index, row) {
      const table2 = this.$refs.table2
      const tableData = this.$refs.table2.getData()
      let isDefalut = false
      if (tableData[index].IS_DEFAULT === 10041001 && tableData.length > 1) {
        isDefalut = true
      }
      table2.delete(index)

      if (isDefalut) {
        const tableData2 = this.$refs.table2.getData()
        tableData2[0].IS_DEFAULT = 10041001
      }
    },
    tableDefault(index, row) {
      const table2 = this.$refs.table2.getData()
      table2.forEach((res, idx) => {
        if (idx === index) {
          res.IS_DEFAULT = 10041001
        } else {
          res.IS_DEFAULT = 10041002
        }
      })
    },
    // 禁用
    disableStatus(data) {
      console.dir(data)
      const id = data.EMP_ID
      this.$confirm('是否禁用', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(() => {
          this.$message({
            type: 'success',
            message: '禁用成功!'
          })
          stopById(id).then(res => {
            this.searchHandle()
          })
        })
        .catch(err => {
          this.$message({
            type: 'info',
            message: '已取消禁用'
          })
        })
    },
    // 启用
    enableStatus(data) {
      const id = data.EMP_ID
      this.$confirm('是否启用', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(() => {
          this.$message({
            type: 'success',
            message: '启用成功!'
          })
          startById(id).then(res => {
            this.searchHandle()
          })
        })
        .catch(err => {
          this.$message({
            type: 'info',
            message: '已取消启用'
          })
        })
    },
    // 白名单
    enableWhite(whiteStatus, empId) {
      let whiteStr
      if (whiteStatus === 10041002) {
        whiteStr = '移除'
      } else if (whiteStatus === 10041001) {
        whiteStr = '加入'
      }
      this.$confirm('是否' + whiteStr + '白名单', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(() => {
          whiteEnable(empId, whiteStatus).then(res => {
            this.$message({
              type: 'success',
              message: whiteStr + '成功!'
            })
            this.searchHandle()
          })
        })
        .catch(err => {
          console.error(err)
        })
    },
    // 查询列表选择
    handleSelectionChange(val) {
      this.authSelection = val
    },
    // 角色列表选择
    SelectionChange(val) {
      this.multipleSelection = val
    },
    req() {
      const val = this.multipleSelection
      if (val.length === 0) {
        this.$message({
          type: 'info',
          message: '请选择一条数据!'
        })
        return false
      }
      const table1 = this.$refs.table1
      table1.AuthPush(val)
      const table2 = this.$refs.table2
      const tableDataBef = table2.getData()
      if (tableDataBef.length === 0) {
        val.forEach((res, index) => {
          res.IS_DEFAULT = index === 0 ? 10041001 : 10041002
        })
      } else {
        val.forEach((res, index) => {
          res.IS_DEFAULT = 10041002
        })
      }
      table2.AuthPush(val)

      this.dialogVisible = false
      this.$message({
        type: 'success',
        message: '添加成功!'
      })
    },
    // 角色选择分页
    handleSizeChange(size) {
      this.roleSearch.limit = size
      this.searchRole()
    },
    handleCurrentChange(page) {
      this.roleSearch.pageNum = page
      this.searchRole()
    },
    // 保存
    save() {
      const allocatedList = this.$refs.table1.data()
      allocatedList.forEach(item => {
        item['positionId'] = item.POSITION_ID
        item['positionName'] = item.POSITION_NAME
      })
      const data = {
        ids: this.ids,
        type: this.type,
        allocatedList: allocatedList
      }
      SaveAuth(data).then(res => {
        this.$message({
          type: 'success',
          message: '保存成功!'
        })
        this.active = 1
        this.searchHandle()
      }).catch(err => {

      })
    },
    // 编辑保存
    editSave() {
      this.$refs['editSearchForm'].validate(valid => {
        if (valid) {
          const allocatedList = this.$refs.table2.data()
          allocatedList.forEach(item => {
            item['positionId'] = item.POSITION_ID
            item['positionName'] = item.POSITION_NAME
            item['isDefault'] = item.IS_DEFAULT
            item['isSyncBeidi'] = item.IS_SYNC_BEIDI
            item['areaType'] = item.AREA_TYPE
          })
          const data = {
            userCode: this.form.userCode,
            userStatus: this.form.userStatus,
            employeeId: this.EMPLOYEE_ID,
            ids: this.EMPLOYEE_ID,
            type: this.type,
            allocatedList: allocatedList
          }
          SaveAuth(data).then(res => {
            this.$message({
              type: 'success',
              message: '保存成功!'
            })
            this.active = 1
            this.searchHandle()
          }).catch(err => {

          })
        }
      })
    },
    // 返回清空列表
    clear() {
      const table1 = this.$refs['table1']
      table1.filData(this.returnList)
      const table2 = this.$refs['table2']
      table2.filData(this.returnList)
      this.ids = 0
      this.type = 0

      this.active = 1
    }
  }
}

</script>

<style scoped>

</style>
